package com.youchuang.action.admin;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.youchuang.action.BaseAction;
import com.youchuang.bean.Category;
import com.youchuang.common.Constant;
import com.youchuang.service.MainService;

import net.sf.json.JSONArray;

/**
 * 根据父目录查询子目录
 * 
 * @author Administrator
 *
 */
@Namespace(value = "/admin")
@ParentPackage("shopping-default")
public class CategoryFindAction extends BaseAction {
	private static Logger logger = Logger.getLogger(CategoryFindAction.class.getSimpleName());
	private String id;
	private List<Category> categorieList;
	@Resource
	private MainService mainService;

	@Action(value = "categoryFindById", results = { @Result(name = Constant.SUCCESS, type = "json") })
	public String categoryFindById() throws Exception {
		logger.info("categoryFindById is execute");
		categorieList = mainService.findCategoryByParentId(id);
		logger.info("response json cats = " + JSONArray.fromObject(categorieList).toString());
		return Constant.SUCCESS;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public List<Category> getCategorieList() {
		return categorieList;
	}

	public void setCategorieList(List<Category> categorieList) {
		this.categorieList = categorieList;
	}

}
